package com.hymall.util;

import java.util.Date;

/**
 * @author: 叶熠彬
 * @description: 用于Date类型之间的运算
 * @date: 2022/7/19 15:47
 */
public class DateUtils {
    /**
     * 根据天数和开始日期计算结束日期
     *
     * @author: 叶熠彬
     * @date: 2022/7/19 15:49
     * @param: [days, startDay]
     * @return: java.util.Date
     */
    public static Date addDays(int days, Date startDay) {
        long time = startDay.getTime();
        time += days * (24 * 60 * 60 * 1000);
        Date endDay = new Date(time);
        return endDay;
    }

    /**
     * 根据起始日期和分钟数计算结束时间
     *
     * @author: 叶熠彬
     * @date: 2022/7/20 14:25
     * @param: [startDay, min]
     * @return: java.util.Date
     */
    public static Date addMinutes(Date startDay, int min) {
        long time = startDay.getTime();
        time += min * (60 * 1000);
        Date endDay = new Date(time);
        return endDay;
    }
}
